package com.hqyj.dao;

import com.hqyj.entity.Info;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Repository
public interface InfoDao extends JpaRepository<Info,Integer> {

//    @Query(nativeQuery = true,value = "insert into info (infoname,infodate,infocontant,infostate,user_id) values (:#{#info.infoname},:#{#info.infodate},:#{#info.infocontant},:#{#info.infostate}},:#{#info.user_id})")
//    int insertInfo(@Param("info") Info info);

    @Transactional
    @Modifying
    @Query(nativeQuery = true,value = "insert into info (infoname,infodate,infocontant,infostate,user_id) values (:infoname,:infodate,:infocontant,:infostate,:user_id)")
    int insertInfo(@Param("infoname")String infoname, @Param("infodate")Date infodate, @Param("infocontant")String infocontant, @Param("infostate")String infostate, @Param("user_id")Integer user_id);
}
